﻿using Microsoft.EntityFrameworkCore;

namespace EntityModel
{
    /// <summary>
    /// 数据上下文
    /// </summary>
    public class HallDbContext:DbContext
    {
        public HallDbContext(DbContextOptions<HallDbContext> opts):base(opts) { }

        /// <summary>
        /// 人员信息
        /// </summary>
        public DbSet<EM_User> EM_User { get; set; }

        /// <summary>
        /// 菜品、菜单
        /// </summary>
        public DbSet<EM_BillFare> eM_BillFare { get; set; }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<EM_User>().HasData(
                [
                    new EM_User(){
                        FirstName="张",
                        LastName="三",
                        Type=0,
                        Pay=10000,
                        Gender=true,
                        Age=30,
                        AddTime=DateTime.Now
                    },
                    new EM_User(){
                        FirstName="李",
                        LastName="四",
                        Type=1,
                        Pay=5000,
                        Gender=false,
                        Age=23,
                        AddTime=DateTime.Now
                    }
                ]
                );
        }
    }
}
